namespace{

//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
//
//      Step 0
//
//          Create temp tables for obsolete accessions
//
//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
// eCREATE_OBSOLETE_ACC_TABLES
string SQL_descriptions_stage0[] =
{
	string("create the temporary table for accessions marked for deletion."		)
};

string SQL_commands_stage0[] =
{
	string(	"CREATE TEMP TABLE obsolete_accid(accid oid) "  			)
};


//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
//
//      Step 1
//
//          Delete and archive accessions and secondary IDs
//
//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
// eANALYSE_OBSOLETE_ACC
string SQL_descriptions_stage1[] =
{
	string("Create PostgreSQL index on obsolete accessions for deletion."			),
//	string("Update PostgreSQL stats on obsolete accessions for deletion."			),
	string("Update PostgreSQL stats on accessions."									),
	string("Update PostgreSQL stats on sequences."									)
};

string SQL_commands_stage1[] =
{
    string(	"CREATE UNIQUE INDEX t_i_ob1 ON obsolete_accid (accid)"),
//    string(	"ANALYSE obsolete_accid"),
    string(	"ANALYSE sequences"),
    string(	"ANALYSE accessions")
};

//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
//
//      Step 2
//
//          Delete and archive accessions and secondary IDs
//
//8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
// eREMOVE_OBSOLETE_ACC
string SQL_descriptions_stage2[] =
{
	string("delete obsolete secondary IDs."			),
	string("archive obsolete accessions."			),
	string("remove obsolete accessions."			)
};

string SQL_commands_stage2[] =
{
#ifdef NDEBUG
	string(	"DELETE FROM secondary_ids USING obsolete_accid WHERE secondary_ids.secid_accid = obsolete_accid.accid"),
	string( "INSERT INTO archived_accessions                        "
			"     SELECT tax_id, acc_hash, prot_id,                                "
			"            acc_name, db_origin, acc_text, acc_date_added              "
			"         FROM obsolete_accid                                           "
			"         NATURAL JOIN accessions a                                     "),
	string(	"DELETE FROM accessions USING obsolete_accid WHERE accessions.accid = obsolete_accid.accid")
#else
	string(	"EXPLAIN ANALYSE DELETE FROM secondary_ids USING obsolete_accid WHERE secondary_ids.secid_accid = obsolete_accid.accid"),
	string( "EXPLAIN ANALYSE INSERT INTO archived_accessions                        "
			"     SELECT tax_id, acc_hash, prot_id,                                "
			"            acc_name, db_origin, acc_text, acc_date_added              "
			"         FROM obsolete_accid                                           "
			"         NATURAL JOIN accessions a                                     "),
	string(	"EXPLAIN ANALYSE DELETE FROM accessions USING obsolete_accid WHERE accessions.accid = obsolete_accid.accid")
#endif
};


}
